package com.wgts.wgts.control.pagertitle;

import android.content.Context;
import android.graphics.Rect;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wgts.wgts.R;

import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IMeasurablePagerTitleView;


public class TimeActionPagerTitleView extends LinearLayout implements IMeasurablePagerTitleView {

    private TextView textActionTime, textActionState;

    private LinearLayout linearLayout;

    private View viewTag;

    private int mSelectedColor;

    private int mNormalColor;


    public TimeActionPagerTitleView(Context context) {
        super(context);
        View view = LayoutInflater.from(context).inflate(R.layout.time_action_title, this);
        textActionTime = view.findViewById(R.id.text_time_action);
        textActionState = view.findViewById(R.id.text_action_state);
        viewTag = view.findViewById(R.id.view_tag);
    }

    private void initView(Context context){

        //linearLayout = view.findViewById(R.id.linea_layout);
    }

    @Override
    public int getContentLeft() {
        Rect bound = new Rect();
        return getLeft() + getWidth() / 2;
    }

    @Override
    public int getContentTop() {

        return (int) (getHeight() / 2);
    }

    @Override
    public int getContentRight() {
        Rect bound = new Rect();

        return getLeft() + getWidth() / 2;
    }

    @Override
    public int getContentBottom() {

        return (int) (getHeight() / 2 );
    }

    @Override
    public void onSelected(int index, int totalCount) {
        //setBackgroundColor(mSelectedColor);
        textActionTime.setTextColor(mSelectedColor);
        textActionState.setTextColor(mSelectedColor);
        viewTag.setVisibility(VISIBLE);
    }

    @Override
    public void onDeselected(int index, int totalCount) {
        //setBackgroundColor(mNormalColor);
        textActionTime.setTextColor(mNormalColor);
        textActionState.setTextColor(mNormalColor);
        viewTag.setVisibility(INVISIBLE);
    }

    @Override
    public void onLeave(int index, int totalCount, float leavePercent, boolean leftToRight) {

    }

    @Override
    public void onEnter(int index, int totalCount, float enterPercent, boolean leftToRight) {

    }

    public int getSelectedColor() {
        return mSelectedColor;
    }

    public void setSelectedColor(int selectedColor) {
        mSelectedColor = selectedColor;
    }

    public int getNormalColor() {
        return mNormalColor;
    }

    public void setNormalColor(int normalColor) {
        mNormalColor = normalColor;
    }

    public void setTextActionTimeText(String text){

        textActionState.setText(text);
    }

    public void setTextActionStateText(String text){
        textActionTime.setText(text);
    }
}
